home *** CD-ROM | disk | FTP | other *** search
- /* ShowRegisteredSCSIDEvices.c */
- /*
- * ShowRegisteredSCSIDEvices.c
- * Copyright © 1992-94 Apple Computer Inc. All Rights Reserved.
- *
- * This subroutine prints the bus ID and driver refNum for all drivers
- * registered with SCSI Manager 4.3
- */
- #include <stdio.h>
- #include <Files.h>
- #include <Devices.h>
- #include <Memory.h>
- /*
- * Include the O.S. files in a specific order to make sure that we have
- * a definition for the _SCSIAtomic trap.
- */
- #include <Traps.h>
- #ifndef _SCSIAtomic
- #define _SCSIAtomic 0xA089
- #endif
- /*
- * Note that this uses a later version of <Scsi.h> than is available in
- * the published headers.
- */
- #include "Scsi.h"
-
- Boolean AsyncSCSIPresent(void);
- void ShowRegisteredSCSIDevices(void);
-
- static void
- ClearMemory(
- Ptr ptr,
- Size size
- )
- {
- while (size > 0) {
- *ptr++ = 0;
- --size;
- }
- }
-
-
- void
- ShowRegisteredSCSIDevices(void)
- {
- SCSIDriverPB pb;
- OSErr status;
- int foundCount;
-
- if (AsyncSCSIPresent()) {
- ClearMemory((Ptr) &pb, sizeof pb);
- pb.scsiPBLength = sizeof (SCSIDriverPB);
- pb.scsiCompletion = NULL;
- pb.scsiFlags = 0;
- pb.scsiFunctionCode = SCSILookupRefNumXref;
- * ((long *) &pb.scsiDevice) = 0xFFFFFFFFL;
- foundCount = 0;
- do {
- status = SCSIAction((SCSI_PB *) &pb);
- if (status == noErr) {
- if (pb.scsiDevice.bus != 0xFF) {
- printf("Device ID [%d.%d.%d], %3d refNum\n",
- (int) pb.scsiDevice.bus,
- (int) pb.scsiDevice.targetID,
- (int) pb.scsiDevice.LUN,
- (int) pb.scsiDriver
- );
- ++foundCount;
- }
- pb.scsiDevice = pb.scsiNextDevice;
- }
- }
- while (pb.scsiDevice.bus != 0xFF);
- switch (foundCount) {
- case 0: printf("No devices were registered\n"); break;
- case 1: printf("One device was registered\n"); break;
- default: printf("%d devices were regisered\n", foundCount); break;
- }
- }
- else {
- printf("SCSI Manager 4.3 is not present on this machine\n");
- }
- }
-
-
-